	<title>权限菜单版本设置</title>
	<style>	
	</style>
	<link rel="stylesheet" type="text/css" href="__STATIC__/js/layui256/layui/css/layui.css">
</head>
<body>
	<div class="layui-tab">
		<ul class="layui-tab-title">
			<?php $currentTab = 3;?>
			<include file="rbac_menu/public/nav">
		</ul>
		<fieldset class="layui-elem-field site-demo-button" style="margin-top: 30px;">
  			<legend>搜索</legend>
			<form class="layui-form" action="{:url('authorization/RbacModule/index')}">
				<div>
					<div class="layui-form-item">
						<div class="layui-inline">
				      		<label class="layui-form-label">公司名称</label>
						      <div class="layui-input-inline">
						        <select name="company" lay-verify="required" lay-search="">
						          <option value="">选择公司名称</option>
							        <volist name='$companyList' id="vo">
							          <option value="{$vo.id}" <?php if( $company == $vo['id']) echo 'selected';?> >{$vo.company_name}</option>
							      </volist>
						        </select>
						        
						      </div>
						</div>
						<div class="layui-inline">
						    <div class="layui-input-inline">
						       	<button type="submit" class="layui-btn">搜索</button>
						    </div>
						</div>
					</div>
				</div>
			</form>
		</fieldset>
		<div class="layui-col-md12">
			<table class="layui-table">
			<colgroup>
				<col width="60">
				<col>
				<col>
				<col>
				<col>
				<col width="200">
			</colgroup>
				<thead>
					<tr>
						<th>STOREID</th>
						<th>模块名</th>
						<th>标识</th>
						<th>版本</th>
						<th>描述</th>
						<th>操作&nbsp;&nbsp;<button type="button" class="layui-btn layui-btn-xs layui-btn-radius btn-addmokuai">授权模块</button></th>
					</tr>
				</thead>
				<tbody>
					<volist name="list" id="vo">
					<tr>
						<td>{++$key}</td>
						<td>{$vo.title}</td>
						<td>{$vo.name}</td>
						<td>{$vo.version}</td>
						<td>{$vo.describe}</td>
						<td>
							<!--button type="button" class="layui-btn layui-btn-xs layui-btn-radius" onclick="setBaseMenu({$vo.store_id});">菜单设置</button-->
							<button  type="button"  href="{:url('authorization/RbacModule/delete')}?id={$vo.store_id}&cid={$company}" data-msg="确定取消此模块授权吗?" class="layui-btn layui-btn-xs layui-btn-radius layui-btn-danger zy-ajax-confirm">取消授权</button>
						</td>
					</tr>
					</volist>
				</tbody>
			</table>
			<empty name="list">
				暂无数据~
			</empty>
		</div>
	</div>
<script src="__STATIC__/js/jquery.js"></script>
<script src="__STATIC__/js/layui256/layui/layui.all.js"></script>
<script src="__STATIC__/js/layer/layer.js"></script>
<script src="__STATIC__/js/custom/custom.js"></script>
<script type="text/javascript">
	var addVersion = function( id = '' ){
		layer.open({
			offset:'100px;',
			type: 2,
			title:'权限菜单版本设置',
			area: ['700px', '450px'],
			fixed: false, //不固定
			maxmin: true,
			btn:['提交','取消'],
			content: '{:url("authorization/RbacMenuVersion/add")}'+((id=='')?"":"?id="+id+"&edit=edit"),
			yes:function( index , layero ){
				var res = $(layero).find("iframe")[0].contentWindow.callback();
				if( id != '' ){
					res ['id'] = id;
					res ['edit'] = 'edit';
				}
				$.post( '{:url("authorization/RbacMenuVersion/add")}', res , function( data ){
					//data = JSON.parse( data );
					let icon = ( data.code == 200 )? 1 : 5;
					layer.msg( data.message , { time:1500, icon:icon } ,function(){
						if(icon ==1 ) window.location.reload(); 
					} );
				} , 'json' );
			}
		});
	}

	var setBaseMenu = function( versionId ){
		var layerNum = layer.open({
			type: 2,
			title:'版本菜单设置',
			area: ['700px', '80%'],
			fixed: false, //不固定
			maxmin: true,
			btn:['保存','取消'],
			content: '{:url("authorization/RbacMenuVersion/setBaseMenu")}?versionId='+versionId,
			yes:function( index , layero ){
				var res = $(layero).find("iframe")[0].contentWindow.getChecked();
				$.post( '{:url("authorization/RbacMenuVersion/baseMenuPost")}', {list:res,versionId:versionId} , function( data ){
					//data = JSON.parse( data );
					let icon = ( data.code == 200 )? 1 : 5;
					layer.msg( data.message , { time:1500, icon:icon } , function (){
						if( icon == 1 ) layer.close(layerNum);
					});
				} , 'json' );
			}
		});
	}

	$(document).on( 'click' , '.btn-addmokuai' , function(e){
		e.stopPropagation();
		let cid = $('select[name=company]').val();
		if( cid.length == 0 ){
			layer.msg( '请选择公司' );
			return false;
		}
		//自定义 html 页面
		layer.open({
			type: 2
			,title:'授权模块'
			,offset:['100px']
			,id:'open-box'
			,area:['700px', '80%']
			,btn: ['确定', '取消']
			,content: '{:url("authorization/RbacModule/selectModule")}?cid='+cid
			,scrollbar: false  //弹窗时禁止父级页面滚动
			,yes: function(index, layero){
				var res = $(layero).find("iframe")[0].contentWindow.saveModule( index , cid );
			}
			,success: function(layero, index){   //弹框成功后执行

			},
		});
		return false;
	} );
</script>
</body>
</html>